<!DOCTYPE html>
<html>
<script src="../../../../resources/js-test.js"></script>
<link rel="stylesheet" href="../resources/touch-hover-active-tests.css">
<style type="text/css">
#box {
    width: 300px;
    height: 100px;
}
</style>
<body>
<div id="box" class="touch-interactive">Gestures go here</div>

<p id="description"></p>
<p>See http://crbug.com/316974 for details</p>

<div id="console"></div>

<script src="../resources/touch-hover-active-tests.js"></script>
<script>
var box = document.getElementById("box");
description("Tests that gesture tapcancel clears hover properly");

function runTests()
{
    if (!window.eventSender) {
        debug('This test requires DRT.');
        return;
    }

    if (!eventSender.gestureShowPress
        || !eventSender.gestureTapCancel) {
        debug('Gesture events are not supported by this platform');
        return;
    }

    debug("Verify hover, active aren't initially set");
    shouldBeDefault("getHoverActiveState(box)");

    debug("tapCancel on element when it is Active should keep hover");
    eventSender.gestureTapDown(50, 50);
    eventSender.gestureShowPress(50, 50);
    shouldBeHoveredAndActive("getHoverActiveState(box)");
    eventSender.gestureTapCancel(50, 50);
    shouldBeOnlyHovered("getHoverActiveState(box)");

    debug("tapCancel outside element when it is Active should clear it");
    eventSender.gestureTapDown(50, 50);
    eventSender.gestureShowPress(50, 50);
    shouldBeHoveredAndActive("getHoverActiveState(box)");
    eventSender.gestureTapCancel(400, 250);
    shouldBeDefault("getHoverActiveState(box)");

    debug("tapCancel on element when it is hovered but not active should keep hover");
    eventSender.mouseMoveTo(50, 50);
    shouldBeOnlyHovered("getHoverActiveState(box)");
    eventSender.gestureTapCancel(50, 50);
    shouldBeOnlyHovered("getHoverActiveState(box)");

    debug("tapCancel outside element when it is hovered but not active should keep hover");
    eventSender.mouseMoveTo(50, 50);
    shouldBeOnlyHovered("getHoverActiveState(box)");
    eventSender.gestureTapCancel(400, 250);
    shouldBeOnlyHovered("getHoverActiveState(box)");
}

window.onload = runTests;
</script>
</body>
</html>

